/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package services.Impl;

import java.util.Collection;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import models.Tables;
import services.interfaces.ITableService;

/**
 *
 * @author Yaroslav
 */

@Stateless
@LocalBean
public class TableServiceImpl extends GenericServiceImpl<Tables> implements ITableService {

     @PersistenceContext(unitName="orsPU")
    private EntityManager em;
    
    public TableServiceImpl() {
        super(Tables.class);
    }
    
    @Override
    protected EntityManager getEntityManager() {
        return this.em;
    }

    @Override
    public Collection<Tables> getTableBySeats(int countSeats) {
       Query q = em.createNamedQuery("Tables.findByCountSeats").setParameter("countSeats", countSeats);
       Collection entities = q.getResultList();
       return  entities;
    }

//    @Override
    public Collection<Tables> getTablesById(Long id) {
       Query q = em.createNamedQuery("Tables.findById").setParameter("id", id);
       Collection entities = q.getResultList();
       return  entities;
    }
    
}
